<template>
	<view class="content">
		<view class="clickToSearch">
			<view class="box">
				<span>
				<uni-icons class="right-icon" type="search" size="20" color="#7f7f7f"></uni-icons>
				<text class="right-text">搜索全部兴趣小组</text>
				</span>
			</view>
		</view>
		<view class="t-list">
			<text class="t-item" v-for="(item,index) in chooseItems":key="index" @click="onClickItem":id=index hover-class="t-item2">
				<text class="text">{{item}}</text>
			</text>
		</view>
<!-- 		<view class="choose-new-hot">
			<text v-for="(item,index) in chooseItems"@click="onClickItem":id="index" class="new-hot":class="chooseIndex==index?'new-hot-active':''">{{item}}</text>
		</view> -->
		<view class="search">
			<view class="searchBox">
				<view class="allGroup">
					<view v-if="allGroup.length!==0">
						<view class="allGroupBox" v-for="(row,index) in allGroup" :key="index">
							<view class="box_top">
								<image :src="row.groupImg" mode="" class="head"></image>
								<view class="right">
									<p class="name">{{row.groupName}}</p>
									<p class="p2">
										<text class="text1">{{row.groupNum}}个{{row.groupName}}爱好者</text>
									</p>
									<p class="p3">
										<button v-if="row.isFollow==true">已加入</button>
										<button class="noFollow" v-if="row.isFollow==false">加入+</button>
									</p>
								</view>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		onLoad() {
			this.getAllGroup(this.userId, this.groupType);
			
		},
		data() {
			return {
				userId: "1323570089@qq.com",
				groupType: "学习",
				allGroup: [],
				chooseItems:["学习","活动","舞台剧","绘画","相声","音乐","植物","书法","缝纫","艺术"],
				chooseIndex:0,
			}
		},
		methods: {

			onClickItem(e) {
				console.log(e);
				this.chooseIndex = e.currentTarget.id;
				this.groupType=this.chooseItems[this.chooseIndex];
				console.log(this.groupType);
				this.getAllGroup(this.userId,this.groupType);
			},
			getAllGroup(userId, groupType) {
				uni.request({
					url: "http://ronin.fun:8888/group/all",
					data: {
						userId: userId,
						groupType: groupType,
		
					},
					success: (res) => {
						this.allGroup = res.data.data;
						console.log(res.data);
					}
				})
				console.log(groupType);
			},

		}
	}
</script>

<style lang="scss">
	.content {
		width: 100%;
		height: 100%;
		.clickToSearch{
			display: flex;
			.cancel{
				margin: 30rpx 30rpx 20rpx 20rpx;
				display: inline-block;
				font-size: 35rpx;
				color: #333333;
			}
			.box{
				display: inline-block;
				margin: 30rpx 10rpx 20rpx 30rpx;
				height: 55rpx;
				background-color: #F2F2F2;
				border-radius: 45rpx;
				border: 1px solid #F2F2F2;
				flex: 1;
				.right-icon{
					margin-left: 10rpx;
					margin-top: 30rpx;
				}
				.right-text{
					margin-left: 170rpx;
					color: #7f7f7f;
				}
			}
		}
		.t-list{
				display:flex;
				width:100%;
				height: 100rpx;
				flex-direction: row;
				overflow-x: scroll;
				overflow-y: hidden;
				margin-top: 10rpx;
				margin-bottom: 5rpx;
				
				.t-item{
					flex-shrink: 0;
					display: flex;
					justify-content: center;
					align-items: center;
					flex-direction: column;
					width: 176upx;
					font-size: 26upx;
					color: #666;
					

					.text{
						color:#000000;
						font-weight: bold;
						margin-top: 5rpx;
						margin-bottom: 0rpx;
					}
					.allgroup{
						height: 100rpx;
						width: 100rpx;
					}
				}
			}
		.t-list::-webkit-scrollbar {
		        display: none;
		    }
		
		
		.t-item2{
			background-color: #F1F1F1;
		}
		.choose-new-hot{
			width: 100%;
			height: 100rpx;
			margin-top: 20rpx;
			margin-left: 20rpx;
			display: flex;
			.new-hot{
				flex: 1;
				// margin-left: 30rpx;
				color: #555555;
				font-size: 35rpx;
				
			}
			.new-hot-active{
				flex: 1;
				// margin-left: 30rpx;
				color: #B0E3FF;
				font-size: 35rpx;
				font-weight: bold;
			}
		}
		.search {
			padding: 0 4%;

			.searchBox {
				.allGroup {
					background-color: #ffffff;
					overflow: hidden;

					.allGroupBox {
						overflow: hidden;
						margin-top: 20upx;
						padding-bottom: 20upx;
						overflow: hidden;
						border-bottom: 1upx solid #f2f2f2;

						&:last-child {
							border-bottom: none;
							padding-bottom: 10upx;
						}

						.box_top {
							display: flex;

							.head {
								height: 150upx;
								max-width: 150upx;
								min-width: 150upx;
								flex: 1;
								border-radius: 50%;
								float: left;
							}

							.right {
								flex: 1;
								margin-left: 20upx;
								position: relative;

								.name {
									padding-left: 10upx;
									padding-top: 10upx;
									font-size: 35upx;
									font-family: Source Han Sans CN;
									font-weight: 400;
									color: rgba(0, 0, 0, 1);
								}

								.p2 {
									padding-left: 10upx;
									padding-top: 20upx;
									margin-top: 20upx;
									font-size: 35upx;
									font-family: Source Han Sans CN;
									font-weight: 400;
									color: rgba(156, 156, 156, 1);

									.text2 {
										margin-left: 50upx;
									}
								}

								.p3 {
									height: 35upx;
									position: absolute;
									right: 0;
									width: 150upx;
									top: 20upx;

									.noFollow {
										background-color: #007AFF;
										color: #FFFFFF;

										-webkit-border-top-left-radius: 12px;
										-moz-border-radius-topleft: 12px;
										border-top-left-radius: 12px;
										-webkit-border-top-right-radius: 12px;
										-moz-border-radius-topright: 12px;
										border-top-right-radius: 12px;
										-webkit-border-bottom-left-radius: 12px;
										-moz-border-radius-bottomleft: 12px;
										border-bottom-left-radius: 12px;
										-webkit-border-bottom-right-radius: 12px;
										-moz-border-radius-bottomright: 12px;
										border-bottom-right-radius: 12px;
										background-color: #169bd5;
										padding-left: 15rpx;
										padding-right: 15rpx;
									}

									image {
										width: 35upx;
										height: 35upx;
										float: left;
										margin-left: 5upx;
									}
								}
							}
						}
					}
				}
			}
		}
	}
</style>
